const app = getApp()
import util from '../../../utils/util'
import {
  GetDhsqList
} from '../../../config/api'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    isEmpty:false,
    grider_storge: '',
    //  grider_storge: {
    //   id: 9,
    //   pid:8,
    //   name: '王群',
    //   vollege_id: 6,
    //   town_id: 5
    // }, // 网格员缓存信息
    page: 1,
    limit: 10,
    lists: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    let grider_storge = wx.getStorageSync('grider')
    this.setData({
      grider_storge: grider_storge // 正式打开,
    })

    this.getLists();

  },

  getLists() {
    let that = this;
    let params = {
      id: this.data.grider_storge.id,
      page: this.data.page,
      limit: this.data.limit
    }

    util.apiRequest(GetDhsqList, params, null).then(r => {
      console.log('电话诉求列表：', r)
      var newList = that.data.lists.concat(r.data.data.data)

      if (r.data.data.data == '') {
        wx.showToast({
          title: '暂无更多',
          icon: 'none',
        })
      }

      that.setData({
        lists: newList
      })

      wx.hideLoading();

      if (newList.length == 0) {
        that.setData({
          isEmpty: true
        })
      } else {
        that.setData({
          isEmpty: false
        })
      }

    })
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {
    var that = this;
    var page = this.data.page;
    page++;
    that.setData({
      page: page
    })
    console.log('page++', page)
    this.getLists();
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})